package com.ruoyi.community.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.community.mapper.SimpleNoticeSectionMapper;
import com.ruoyi.community.domain.SimpleNoticeSection;
import com.ruoyi.community.service.ISimpleNoticeSectionService;

/**
 * 公告板块Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-12-10
 */
@Service
public class SimpleNoticeSectionServiceImpl implements ISimpleNoticeSectionService 
{
    @Autowired
    private SimpleNoticeSectionMapper simpleNoticeSectionMapper;

    /**
     * 查询公告板块
     * 
     * @param sectionId 公告板块ID
     * @return 公告板块
     */
    @Override
    public SimpleNoticeSection selectSimpleNoticeSectionById(String sectionId)
    {
        return simpleNoticeSectionMapper.selectSimpleNoticeSectionById(sectionId);
    }

    /**
     * 查询公告板块列表
     * 
     * @param simpleNoticeSection 公告板块
     * @return 公告板块
     */
    @Override
    public List<SimpleNoticeSection> selectSimpleNoticeSectionList(SimpleNoticeSection simpleNoticeSection)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        simpleNoticeSection.setCommunityId(Long.valueOf(loginUser.getCommunityId()));
        return simpleNoticeSectionMapper.selectSimpleNoticeSectionList(simpleNoticeSection);
    }

    /**
     * 新增公告板块
     * 
     * @param simpleNoticeSection 公告板块
     * @return 结果
     */
    @Override
    public int insertSimpleNoticeSection(SimpleNoticeSection simpleNoticeSection)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        simpleNoticeSection.setCreater(loginUser.getUsername());
        simpleNoticeSection.setCommunityId(Long.valueOf(loginUser.getCommunityId()));
        return simpleNoticeSectionMapper.insertSimpleNoticeSection(simpleNoticeSection);
    }

    /**
     * 修改公告板块
     * 
     * @param simpleNoticeSection 公告板块
     * @return 结果
     */
    @Override
    public int updateSimpleNoticeSection(SimpleNoticeSection simpleNoticeSection)
    {
        return simpleNoticeSectionMapper.updateSimpleNoticeSection(simpleNoticeSection);
    }

    /**
     * 批量删除公告板块
     * 
     * @param sectionIds 需要删除的公告板块ID
     * @return 结果
     */
    @Override
    public int deleteSimpleNoticeSectionByIds(String[] sectionIds)
    {
        return simpleNoticeSectionMapper.deleteSimpleNoticeSectionByIds(sectionIds);
    }

    /**
     * 删除公告板块信息
     * 
     * @param sectionId 公告板块ID
     * @return 结果
     */
    @Override
    public int deleteSimpleNoticeSectionById(String sectionId)
    {
        return simpleNoticeSectionMapper.deleteSimpleNoticeSectionById(sectionId);
    }
}
